package com.aizuda.boot.modules.business.contract.service.impl;

import com.aizuda.boot.modules.business.contract.entity.EmployeeTableFilterEntity;
import com.aizuda.boot.modules.business.contract.mapper.EmployeeTableFilterMapper;
import com.aizuda.boot.modules.business.contract.service.EmployeeTableFilterService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeTableFilterServiceImpl 
        extends ServiceImpl<EmployeeTableFilterMapper, EmployeeTableFilterEntity>
        implements EmployeeTableFilterService {

    @Resource
    private EmployeeTableFilterMapper mapper;

    @Override
    public void updateFiltersByEmployeeId(Long employeeId, List<Integer> filters) {
        UpdateWrapper<EmployeeTableFilterEntity> wrapper = new UpdateWrapper<>();
        wrapper.eq("employee_id", employeeId)
                .set("filters", filters.toString());
        mapper.update(null, wrapper);
    }

    @Override
    public EmployeeTableFilterEntity getByEmployeeId(Long employeeId) {
        return mapper.selectByEmployeeId(employeeId);
    }
} 